//
//  HLTZhifumaguanliTableViewCell.m
//  huiliantong
//
//  Created by hlt on 15/9/1.
//  Copyright (c) 2015年 hlt. All rights reserved.
//

#import "HLTZhifumaguanliTableViewCell.h"
#import "HLTerweimaViewController.h"
//#import "QRCodeGenerator.h"
@implementation HLTZhifumaguanliTableViewCell
//这样就可以不用加下划线调用。h文件里面的属性了
@synthesize imageview;

- (void)awakeFromNib {
    // Initialization code
    
//    UIImage *image=[self shengcheng:_zhifuma.text size:200];
//    imageview.image=image;
    
}


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        // 初始化时加载collectionCell.xib文件 这个是把这个xib文件全部加载了，然后取第一个
        NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
        
        // 如果路径不存在，return nil
        if (arrayOfViews.count < 1)
        {
            return nil;
        }
        // 如果xib中view不属于UICollectionViewCell类，return nil
        if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]])
        {
            return nil;
        }
        // 加载nib
        self = [arrayOfViews objectAtIndex:0];
    }
    return self;
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}







- (IBAction)chakanerweima:(id)sender {
    
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    HLTerweimaViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTerweimaViewController"];
    
//    HLTerweimaViewController *vc=[[HLTerweimaViewController alloc]init];
    vc.zhifumastr=self.zhifuma.text;
//    vc.zhifuma.text=self.zhifuma.text;
//    [vc createrweima];
    [self.parent.parent.navigationController pushViewController:vc animated:YES];
    
    
    
}











- (IBAction)querenzhifu:(id)sender {
    
    
    
    UIView *view1=[[UIView alloc] initWithFrame:self.parent.view.bounds];
    view1.backgroundColor=[UIColor grayColor];
    view1.alpha=0.4;
    [self.parent.view addSubview:view1];
    MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
    indicatorView.delegate = self;
    indicatorView.numberOfCircles = 3;
    indicatorView.radius = 20;
    indicatorView.internalSpacing = 3;
    indicatorView.center = self.parent.view.center;
    [indicatorView startAnimating];
    [self.parent.view addSubview:indicatorView];
    
    
    
    
    
    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
    
    
    //支付码确认接口 (user_name=18285117540，amount=金额，serial_number=流水号，payToUser=支付给的商家手机号，shop_id=商铺id，paycode_number=支付码)
    NSString *url=[paykeyqueren stringByAppendingFormat:@"&user_name=%@&amount=%@&serial_number=%@&payToUser=%@&shop_id=%@&paycode_number=%@",acc.custPhone,self.jine.text,self.liushuihao.text,self.toshopphone,self.shop_id,self.zhifuma.text];
    
    [HLTNetWorkingtool getdic:url success:^(NSDictionary *ary) {
        [indicatorView stopAnimating];
        [view1 removeFromSuperview];
        //将nsnumber 装换成nsstring
                    NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
                    NSString *str = [numberFormatter stringFromNumber:ary[@"code"]];
        if ([str isEqual:@"2"]) {
            NSArray *ary1= self.parent.parent.viewControllers;
            for (HLTquanbuTableViewController *order in ary1) {
                
                [order reloadtable];
            }
            
            
            
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:ary[@"msg"]  delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
            [alert show];
            
            NSLog(@"%@",ary);
            
        }else
        {
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:ary[@"msg"] delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
            [alert show];
            
        }
       
   
        //
        
    } faliure:^(NSString *error) {
        [indicatorView stopAnimating];
        [view1 removeFromSuperview];
        
    }];

    
    
    
    
    
}


#pragma mark - MONActivityIndicatorViewDelegate Methods

- (UIColor *)activityIndicatorView:(MONActivityIndicatorView *)activityIndicatorView
      circleBackgroundColorAtIndex:(NSUInteger)index {
    CGFloat red   = (arc4random() % 256)/255.0;
    CGFloat green = (arc4random() % 256)/255.0;
    CGFloat blue  = (arc4random() % 256)/255.0;
    CGFloat alpha = 1.0f;
    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
}





@end
